<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.util.GetBaseParam"%>
<%@page import="crm.util.ParamUtil"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>跟单添加页面</title>
  </head>
  <link type="text/css" href="../../../resources/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
  <script type="text/javascript" src="../../../resources/js/jquery-1.6.2.min.js"></script>
  <script type="text/javascript" src="../../../resources/js/jquery-ui-1.8.16.custom.min.js"></script>
   <script type="text/javascript" src="../../../resources/js/WebCalendar.js"></script>
  <script  type="text/javascript">
	$(function() {
		$( "#findcustomer" ).autocomplete({
			source: function( request, response ) {
			    var http = "auto_find_customer.jsp?term="+request.term,   //避免ie乱码
			    http = encodeURI(http);
				$.ajax({
					url: "auto_find_customer.jsp?term="+request.term,
					dataType: "json",
					success: function( data ) {
						response( $.map( data, function( item ) {
							return {
								td: item.name,
								value: item.name+"  "+item.business+" "+item.areaName,
								id:item.id
								
							}
						}));
					}
				});
			},
			select: function( event, ui ) {
				document.getElementById('consumer').value = ui.item.id;
				$.ajax( {
					type : "get",
					cache : false,
					url : "get_linkman_list.jsp",
					dataType : "html",
					data : {
					consumer : $('#consumer').val()
					},
					success : function(data) {
						$('#linkman_list').html(data);
					}
				})
			}
		});
	});
	$(function() {
		$( "#findemployee" ).autocomplete({
			source: function( request, response ) {
			    var http = "auto_find_employee.jsp?term="+request.term,
			    http = encodeURI(http);
				$.ajax({
					url: http,
					dataType: "json",
					
					success: function( data ) {
						response( $.map( data, function( item ) {
							return {
								td: item.name,
								value: item.name+"  "+item.areaName+" "+item.position,
								id:item.id
							}
						}));
					}
				});
			},
			select: function( event, ui ) {
				document.getElementById('employee').value = ui.item.id;
				
			}
		});
	});
	</script>
  
  <body>
  <%
         Employees cu = (Employees)session.getAttribute("user");
   %>
  <form action="recepit_add_do.jsp" method="post">
  <table>
  <tr>
  <td>跟单项目名称</td><td><input type="text" name="title" /></td></tr>  <tr>
  <td>客户</td><td><input type="text" id="findcustomer" value=""/><input type="hidden" id="consumer" name="consumer"></td><td><a href="../customer/customer_add.jsp">添加客户</a></td></tr>  <tr>
  <td>客户联系人</td><td><select  id="linkman_list" name="linkman_id"></select></td>
  <td>创建人</td><td><input type="text" name="creator" value="<%=cu.getName() %>" readonly></td></tr>  <tr>
  <td>跟单意向</td><td><select name="intention">
        <%  
           HashMap intentions = GetBaseParam.getAllIntentions();
          Iterator it = intentions.entrySet().iterator();
          while(it.hasNext()){
    	       Map.Entry entry = (Map.Entry)it.next();
    	  %>
    	  <option value="<%=entry.getKey() %>"><%=entry.getValue() %></option>
    	  <%
      }%></select></td></tr>  <tr>
  <td>分类</td><td><input type="radio" value="0" name="sort" checked>一般<input type="radio" value="1" name="sort">重要</td></tr>  <tr>
  </tr><tr>
  <td>跟单阶段</td><td><select name="stage">
  <%  
        HashMap stages = GetBaseParam.getAllRecepitStages();
       Iterator it2 = stages.entrySet().iterator();
       while(it2.hasNext()){
    	   Map.Entry entry = (Map.Entry)it2.next();
    	  %>
    	  <option value="<%=entry.getKey() %>"><%=entry.getValue() %></option>
    	  <%
      }
  %></select></td></tr>  <tr>
  <td>跟单人</td><td><input type="text" id="findemployee" /><input type="hidden" id="employee" name="person1" /></td></tr>  <tr>
  <td>预计成交金额</td><td><input type="text" name="predict_amount"/><select name="danwei"><option value="0">元</option><option value="1">万元</option></select></td></tr>  <tr>
  <td>预计成交时间</td><td><input type="text" name="predict_time"  maxlength="20"  onclick="SelectDate(this,'yyyy-MM-dd')" readonly  style="width:100px;cursor:pointer"/></td></tr>  <tr>
  <td>产品</td><td><input type="text" name="product"/></td><%//此处商品需包含产品种类等详细信息 %></tr>  <tr>
  </tr><tr><td><input type="submit" value="提交"></td><td><input type="reset" value="重填"></td>
  </tr>
  </table>
  </form>
  </body>
</html>
